<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/healthmobile.js"></script>
    <style type="text/css">
    .el-main{

        position: absolute;
        top: 70px;
        bottom: 0px;
        left: 200px;
        right: 10px;
        padding: 0;

    }
    </style>
   <!-- <style type="text/css">
        /*
            找到html标签、body标签，和挂载的标签
            都给他们统一设置样式
        */
        html,body,#app,.el-container{
            /*设置内部填充为0，几个布局元素之间没有间距*/
            padding: 0px;
            /*外部间距也是如此设置*/
            margin: 0px;
            /*统一设置高度为100%*/
            height: 100%;
        }
    </style>-->
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div id="app">
        <el-container >
            <el-header  class="main-header" style="height:70px;">
                <nav class="navbar navbar-static-top" :class=''>
                    <!-- Logo -->
                    <a href="#" class="logo" style="text-align:center">
                        <span class="logo-lg"><img src="../img/logo.png"></span>
                    </a>
                    <div class="right-menu">
                        <span class="help"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>帮助</span>
                        <el-dropdown class="avatar-container right-menu-item" trigger="click">
                            <div class="avatar-wrapper">
                                <img src="../img/user2-160x160.jpg" class="user-avatar">
                                {{username}}
                            </div>
                            <el-dropdown-menu slot="dropdown" >
                                <el-dropdown-item divided>
                                    <span style="display:block;"  @click="handleChange()">修改密码</span>
                                </el-dropdown-item>
                                <el-dropdown-item divided>
                                    <span style="display:block;"  @click="testException()">测试BUG发送邮件</span>
                                </el-dropdown-item>
                                <el-dropdown-item divided>
                                    <a href="/logout.do"><span style="display:block;">退出</span></a>
                                    </el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </nav>
            </el-header>
            <el-container >
                <el-aside width="200px" style="height: 650px">
                    <el-scrollbar style="height: 100%">
                    <el-menu>
                        <el-submenu v-for="menu in menus" :index="menu.path">
                            <template slot="title">
                                <i class="fa" :class="menu.icon"></i>
                                {{menu.name}}
                            </template>
                            <template v-for="child in menu.children">
                                <el-menu-item :index="child.path">
                                    <a :href="child.linkUrl" target="right">{{child.name}}</a>
                                </el-menu-item>
                            </template>
                        </el-submenu>
                    </el-menu>
                    </el-scrollbar>
                </el-aside>
                <el-container >
                    <iframe name="right" class="el-main" src="ordersetting.html" width="100%" height="100%" frameborder="0"></iframe>
                </el-container>
            </el-container>
        </el-container>

        <!-- 修改密码标签弹层 -->
        <div class="add-form">
            <el-dialog title="修改密码" :visible.sync="dialogFormVisible4Edit">
                <template>
                    <el-tabs v-model="activeName" type="card">
                        <el-tab-pane label="修改密码" name="first">
                            <el-form label-position="right" :model="formData" ref="dataEditForm" :rules="rules" label-width="100px">
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="验证码" prop="code">
                                            <el-input v-model="formData.code"/>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="验证码">
                                            <el-button :disabled="disable" @click="sendValidateCode()" :disabled="this.disabled">{{this.getCode}}</el-button>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="新密码" prop="password">
                                            <el-input v-model="formData.password"/>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </el-tab-pane>
                    </el-tabs>
                </template>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                    <el-button type="primary" @click="changePassword()">确定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>

    new Vue({
        el: '#app',
        mounted:function () {
            axios.get("/user/getUser.do").then((res)=>{
                this.username = res.data.data;
                axios.get("/user/getMenus/"+this.username+".do").then((res)=>{
                    if (res.data.flag){
                        this.menus = res.data.data;
                        this.$message.success(res.data.message);
                    }else {
                        this.$message.error(res.data.message);
                    }
                })
            });
        },
        data:{
            username:'',
            activeName: 'first',//添加/编辑窗口Tab标签名称
            menuList:[
                {
                    "path": "1",
                    "title": "工作台",
                    "icon":"fa-dashboard",
                    "children": []
                },
                {
                    "path": "2",
                    "title": "会员管理",
                    "icon":"fa-user-md",
                    "children": [
                        {
                            "path": "/2-1",
                            "title": "会员档案",
                            "linkUrl":"member.html",
                            "children":[]
                        },
                        {
                            "path": "/2-2",
                            "title": "上传报告",
                            "linkUrl":"report.html",
                            "children":[]
                        },
                        {
                            "path": "/2-3",
                            "title": "会员统计",
                            "linkUrl":"statistics.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "3",
                    "title": "预约管理",
                    "icon":"fa-tty",
                    "children": [
                        {
                            "path": "/3-1",
                            "title": "预约列表",
                            "linkUrl":"ordersettinglist.html",
                            "children":[]
                        },
                        {
                            "path": "/3-2",
                            "title": "预约设置",
                            "linkUrl":"ordersetting.html",
                            "children":[]
                        },
                        {
                            "path": "/3-3",
                            "title": "套餐管理",
                            "linkUrl":"setmeal.html",
                            "children":[]
                        },
                        {
                            "path": "/3-4",
                            "title": "检查组管理",
                            "linkUrl":"checkgroup.html",
                            "children":[]
                        },
                        {
                            "path": "/3-5",
                            "title": "检查项管理",
                            "linkUrl":"checkitem.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "4",
                    "title": "健康评估",
                    "icon":"fa-stethoscope",
                    "children":[
                        {
                            "path": "/4-1",
                            "title": "体质测评",
                            "linkUrl":"physique-assessment.html",
                            "children":[]
                        },
                        {
                            "path": "/4-2",
                            "title": "心理测评",
                            "linkUrl":"psychoanalysis.html",
                            "children":[]
                        },
                        {
                            "path": "/4-3",
                            "title": "风险评估",
                            "linkUrl":"all-medical-list.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "5",
                    "title": "健康干预",
                    "icon":"fa-medkit",
                    "children":[
                        {
                            "path": "/5-1",
                            "title": "人群分类",
                            "linkUrl": "crowd.html",
                            "children": []
                        },
                        /*{没实现注释
                            "path": "/5-2",
                            "title": "干预方案",
                            "linkUrl": "intervene.html",
                            "children": []
                        },*/
                        {
                            "path": "/5-3",
                            "title": "随访日记",
                            "linkUrl": "follow.html",
                            "children": []
                        },
                        {
                            "path": "/5-4",
                            "title": "指标管理",
                            "linkUrl": "manage.html",
                            "children": []
                        },
                        {
                            "path": "/5-5",
                            "title": "模板管理",
                            "linkUrl": "template.html",
                            "children": []
                        },
                    ]
                },
                {
                    "path": "6",
                    "title": "知识库",
                    "icon":"fa fa-book",
                    "children":[
                        {
                            "path": "/6-1",
                            "title": "评估建议",
                            "linkUrl":"evaluate.html",
                            "children":[]
                        },
                        {
                            "path": "/6-2",
                            "title": "健康方案",
                            "linkUrl":"healthplan.html",
                            "children":[]
                        },
                        {
                            "path": "/6-3",
                            "title": "运动项目库",
                            "linkUrl":"sportslibrary.html",
                            "children":[]
                        },
                        {
                            "path": "/6-4",
                            "title": "膳食库",
                            "linkUrl":"mealslibrary.html",
                            "children":[]
                        },
                        {
                            "path": "/6-5",
                            "title": "疾病库",
                            "linkUrl":"diseaselibrary.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "7",     //菜单项所对应的路由路径
                    "title": "统计分析",     //菜单项名称
                    "icon":" fa-bar-chart-o",
                    "children":[//是否有子菜单，若没有，则为[]
                        {
                            "path": "/7-1",
                            "title": "套餐统计",
                            "linkUrl":"setmealechart.html",
                            "children":[]
                        }
                    ]
                },
                {
                    "path": "8",     //菜单项所对应的路由路径
                    "title": "系统设置",     //菜单项名称
                    "icon":"fa-cog",
                    "children":[//是否有子菜单，若没有，则为[]
                        {
                            "path": "/8-1",
                            "title": "菜单设置",
                            "linkUrl":"menuSettings.html",
                            "children":[]
                        },
                        {
                            "path": "/8-2",
                            "title": "权限管理",
                            "linkUrl":"authorityManage.html",
                            "children":[]
                        },
                        {
                            "path": "/8-3",
                            "title": "用户管理",
                            "linkUrl":"userManage.html",
                            "children":[]
                        },
                        {
                            "path": "/8-4",
                            "title": "角色管理",
                            "linkUrl":"roleManage.html",
                            "children":[]
                        },
                        {
                            "path": "/8-5",
                            "title": "题库管理",
                            "linkUrl":"questionManage.html",
                            "children":[]
                        },
                        {
                            "path": "/8-6",
                            "title": "问卷管理",
                            "linkUrl":"questionnaireManage.html",
                            "children":[]
                        }
                    ]
                }
            ],
            menus:[],
            dialogFormVisible4Edit: false,//控制编辑窗口显示/隐藏
            formData: {},//表单数据
            getCode:'获取验证码',
            disable: false,
            isGeting: false,
            count:30,
            rules: {//校验规则
                code: [{ required: true, message: '验证码为必填项', trigger: 'blur' }],
                password: [{ required: true, message: '新密码为必填项', trigger: 'blur' }],
            }
        },
        methods: {
            testException() {
                this.$message.error("这是用来测试异常的！");
                axios.get("/test/testException.do").then((res) => {
                    if (res.data.flag) {
                        this.$message.success("没有发生异常！");
                    } else {
                        this.$message.error(res.data.message);
                    }
                });
            },
            //修改密码弹出框
            handleChange(){
                this.formData =  {};
                this.dialogFormVisible4Edit = true;
            },
            sendValidateCode(){
                var countDown = setInterval(()=>{
                    if (this.count < 1){
                        this.isGeting = false;
                        this.disable = false;
                        this.getCode = '获取验证码';
                        this.count = 6;
                        clearInterval(countDown)
                    }else {
                        this.isGeting = true;
                        this.disable = true;
                        this.getCode = this.count-- + 's后重发';
                    }
                },1000);
                this.$message.success("系统正在发送验证码，请稍后...");
                axios.get("/user/sendValidateCode.do").then((res) => {
                    if (res.data.flag) {
                        this.$message.success("验证码发送成功！");
                    } else {
                        this.$message.error(res.data.message);
                    }
                });
            },
            changePassword(){
                this.$refs['dataEditForm'].validate((valid)=>{
                    if (valid){
                        axios.post("/user/changePassword.do", this.formData).then((res) => {
                            //判断后台返回的flag值，true表示编辑操作成功，false为编辑操作失败
                            if (res.data.flag) {
                                this.$message.success(res.data.message);
                                window.location.href = "/logout.do";
                            } else {
                                this.$message.error(res.data.message);
                            }
                        }).finally(() => {
                            //隐藏编辑窗口
                            this.dialogFormVisible4Edit = false;
                            //调用分页查询方法
                            this.findPage();
                        })
                    }else {
                        this.$message.error("数据校验失败，请按规则填写");
                        return false;
                    }
                })
            }
        },
    });
    $(function() {
            var wd = 200;
            $(".el-main").css('width', $('body').width() - wd + 'px');
    });

</script>
<el-backtop></el-backtop>
</html>
